package com.wedo.mall.activity.main;

import android.content.Intent;
import android.os.Bundle;

import com.e.library.activity.EActivity;
import com.google.zxing.Result;
import com.wedo.mall.R;

import butterknife.BindView;
import me.dm7.barcodescanner.zxing.ZXingScannerView;

/**
 * Created by lxy on 2017/6/19.
 */

public class ScannerActivity extends EActivity implements ZXingScannerView.ResultHandler{

    @BindView(R.id.xcv_scanner) ZXingScannerView xcv_scanner;


    @Override
    protected int layout() {
        return R.layout.activity_scanner;
    }

    @Override
    protected void onActivityCreated(Bundle state) {
        xcv_scanner.setResultHandler(this);

    }

    @Override
    protected void onStart() {
        super.onStart();
        xcv_scanner.startCamera();
    }

    @Override
    protected void onStop() {
        super.onStop();
        xcv_scanner.stopCamera();
    }

    @Override
    public void handleResult(Result result) {
        xcv_scanner.resumeCameraPreview(this);
        if (result ==null){
            return;
        }

        xcv_scanner.stopCamera();



    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
